<#include "./template/general_temp.ftl">

<#macro content>
<div class="row" xmlns:input="http://www.w3.org/1999/html" xmlns:input="http://www.w3.org/1999/html">
    <div class="box col-md-12">
        <div class="box-inner">
            <div class="box-header well" data-original-title="">
                <h2><i class="glyphicon glyphicon-edit"></i>编辑</h2>

                <div class="box-icon">
                    <a href="#" class="btn btn-setting btn-round btn-default"><i class="glyphicon glyphicon-cog"></i></a>
                    <a href="#" class="btn btn-minimize btn-round btn-default"><i class="glyphicon glyphicon-chevron-up"></i></a>
                    <a href="#" class="btn btn-close btn-round btn-default"><i class="glyphicon glyphicon-remove"></i></a>
                </div>
            </div>
            <div class="box-content">
                <#if !no_obj??>
                    <@form.form modelAttribute="editQuestionCommand" role="form" enctype="multipart/form-data">
                        <@form.errors path='*' element="div" cssClass="alert alert-success" cssErrorClass="alert alert-danger"/>
                        <#if no_error??>
                            <div class="alert alert-success">
                                <strong>Well done! </strong>提交成功。
                            </div>
                        </#if>
                        <div class="form-group">
                            <label for="title">标题</label>
                            <@form.input path="title" cssClass="form-control" id="title"/>
                        </div>
                        <div class="form-group">
                            <label for="content">内容</label>
                            <@form.textarea cssClass="form-control" path="content" id="content"/>
                        </div>
                        <div class="form-group">
                            <label for="status">状态</label>
                            <@form.radiobutton path="status" value="推荐"/>推荐
                            <@form.radiobutton path="status" value="显示"/>显示
                            <@form.radiobutton path="status" value="隐藏"/>隐藏
                        </div>
                        <button type="submit" class="btn btn-default">保存</button>
                    </@form.form>
                    <#if remarks??>
                        <div class="row">
                            <div class="box col-md-12">
                                <div class="box-inner">
                                    <div class="box-header well" data-original-title="">
                                        <h2><i class="glyphicon glyphicon-user"></i>回答</h2>

                                        <div class="box-icon">
                                            <a href="#" class="btn btn-minimize btn-round btn-default"><i class="glyphicon glyphicon-chevron-up"></i></a>
                                            <a href="#" class="btn btn-close btn-round btn-default"><i class="glyphicon glyphicon-remove"></i></a>
                                        </div>
                                    </div>
                                    <div class="box-content">
                                        <table class="table table-striped table-bordered responsive">
                                            <thead>
                                            <tr>
                                                <th>内容</th>
                                                <th>评论时间</th>
                                                <th>评论人</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>

                                        <#list remarks as remark>
                                            <tr>
                                                <td class="center">${remark.content}</td>
                                                <td class="center">${remark.createTimeStr}</td>
                                                <td class="center">${remark.creatorStr}</td>
                                                <td class="center">
                                                    <a class="btn btn-primary" href="#" onclick="del(#{remark.id})">
                                                        <i class="glyphicon glyphicon-trash icon-white"></i>
                                                        删除
                                                    </a>
                                                </td>
                                            </tr>
                                        </#list>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <!--/span-->

                        </div>




                    </#if>
                <#else>
                    <div class="alert alert-danger">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>Oh snap!</strong>没有找到数据！
                    </div>
                </#if>
            </div>
        </div>
    </div>
    <!--/span-->
</div>
<!--/row-->
</#macro>

<#macro script>
<script type="text/javascript">
    function del(id){
        if(window.confirm("确认删除？")) {
            jQuery.ajax({
                type: "POST",
                url: '${base}/system/question/delete',
                dataType:"json",
                data: {"id": id},
                success: function(data){
                    if(data.status == 1) {
                        alert("删除成功！");
                        location.reload();
                    }
                },
                error: function (obj){
                    console.info(obj);
                }
            });
        }
    }
</script>
</#macro>
